# C编译器
CC = gcc

# 源文件
SRCS = mp3_player.c

# 输出二进制文件
TARGET = mp3_player

# FFmpeg库路径（根据实际情况调整）
FFMPEG_INCLUDE = -I/usr/include/ffmpeg
FFMPEG_LIBS = -lavformat -lavcodec -lavutil -lswresample

# ALSA库路径
ALSA_INCLUDE = -I/usr/include/alsa
ALSA_LIBS = -lasound

# Library directories (根据实际情况修改)
LIBDIRS = -L/usr/lib/x86_64-linux-gnu

# 编译选项
CFLAGS = $(FFMPEG_INCLUDE) $(ALSA_INCLUDE) -Wall -g

# 链接选项
LDFLAGS = $(LIBDIRS) $(FFMPEG_LIBS) $(ALSA_LIBS) -lpthread -lm

# 编译规则
all: $(TARGET)

$(TARGET): $(SRCS)
	$(CC) $(CFLAGS) $(SRCS) -o $(TARGET) $(LDFLAGS)

# 清理规则
clean:
	rm -f $(TARGET) *.o

# 测试规则
test:
	@echo "测试1: 显示帮助信息"
	./$(TARGET) -h
	@echo "\n测试2: 检查程序是否能正常解析参数"
	@if [ -f "test.mp3" ]; then echo "测试3: 尝试将MP3解码为PCM文件"; ./$(TARGET) -o test_output.pcm test.mp3; fi
	@echo "\n测试完成！"

.PHONY: all clean test